-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use 'instanceandevents' endpoint when updating process state #937
base: main
Are you sure you want to change the base?
Conversation
} | ||
else | ||
{ | ||
_logger.LogError($"Unable to update instance process with instance id {instance.Id}"); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
This log entry depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 days ago
To fix the problem, we need to sanitize the instance.Id
before logging it. This can be done by removing any newline characters from the instance.Id
to prevent log forging. We will use the String.Replace
method to achieve this.
- Identify the logging statement that uses
instance.Id
. - Sanitize the
instance.Id
by removing newline characters before logging it. - Ensure that the fix does not change the existing functionality of the code.
-
Copy modified lines R190-R191
@@ -189,3 +189,4 @@ | ||
{ | ||
_logger.LogError($"Unable to update instance process with instance id {instance.Id}"); | ||
string sanitizedInstanceId = instance.Id.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogError($"Unable to update instance process with instance id {sanitizedInstanceId}"); | ||
throw await PlatformHttpException.CreateAsync(response); |
…a new instance....
Quality Gate failedFailed conditions |
@@ -683,6 +691,10 @@ [FromRoute] Guid instanceGuid | |||
ProcessChangeResult startResult = await _processEngine.GenerateProcessStartEvents(processStartRequest); | |||
|
|||
targetInstance = await _instanceClient.CreateInstance(org, app, targetInstance); | |||
foreach (var instanceEvent in startResult.ProcessStateChange?.Events ?? []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These loops are needed because GenerateProcessStartEvents
is creating the events, at which point InstanceId
is null..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a bug before this fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, as it started to happen after switching to the new endpoint.. Don't know why, will do some digging to make sure
Description
Uses the new endpoint which commits new process state and instance events in one transaction.
The related tests were a little funny. Test names said they were testing more than they actually were, it seems like most of the variation comes from the
AltinnTaskType
thingy.Related Issue(s)
InstanceEvents
) within a single transaction altinn-storage#544Verification
Documentation